// api/game.js
const { request } = require('./core');

/**
 * 参与活动
 * @param {string} activit_type -	活动类型（签到：CHECK_IN、看广告：ADVERTISEMENT、分享：SHARE）
 * @returns {Promise}
 */
const applyActivities = (params = {}) => {
  return request({
    url: '/user/activities',
    method: 'GET',
    data: params,
    showLoading: true,
    loadingTitle: '提交中...',
  });
};

/**
 * 开始游戏
 * @param {object} params - 查询参数
 * @returns {Promise}
 */
const begin = (params = {}) => {
  return request({
    url: '/game/begin',
    method: 'GET',
    data: params,
    showLoading: true,
    loadingTitle: '提交中...',
  });
};

/**
 * 交易
 * @param {object} params - 查询参数
 * @returns {Promise}
 */
const BuyOrSell = (params = {}) => {
  return request({
    url: '/game/BuyOrSell',
    method: 'GET',
    data: params,
    showLoading: true,
    loadingTitle: '提交中...',
  });
};

/**
 * 游戏结束数据
 * @param {object} params - 查询参数
 * @returns {Promise}
 */
const gameOver = (params = {}) => {
  return request({
    url: '/game/Over',
    method: 'GET',
    data: params,
    showLoading: true,
    loadingTitle: '提交中...',
  });
};

/**
 * 用户投资诊断
 * @param {string} params - 请求参数
 * @returns {Promise}
 */
const getstatistic = (params = {}) => {
  return request({
    url: '/game/getstatistic',
    method: 'GET',
    data: params,
    showLoading: true,
    loadingTitle: '更新中...',
  });
};

/**
 * 获取排行榜
 * @param {object} params - 查询参数
 * @returns {Promise}
 */
const getranking = (params = {}) => {
  return request({
    url: '/game/getranking',
    method: 'GET',
    data: params,
    showLoading: true,
  });
};

// 导出游戏相关的所有接口
module.exports = {
  applyActivities,
  getranking,
  begin,
  BuyOrSell,
  gameOver,
  getstatistic,
};
